package com.baizhi.service.impl;

import com.baizhi.dao.DepartmentDao;
import com.baizhi.entity.Department;
import com.baizhi.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Autowired
    private DepartmentDao departmentDao;

    @Override
    public void insert(Department department) {
        departmentDao.insert(department);
    }

    @Override
    public void update(Department department) {
        departmentDao.update(department);
    }

    @Override
    public void delete(int[] ids) {
        departmentDao.delete(ids);
    }

    @Override
    public void deleteOne(int id) {
        departmentDao.deleteOne(id);
    }

    @Override
    public int selectTotal(String name) {
        return departmentDao.selectTotal(name);
    }

    @Override
    public List<Department> selectDepartmentByPage(int page, int rows, String name) {
        if(name!=null&&"".equals(name)){
            name="%"+name+"%";
        }else {
            name=null;
        }
        int start=(page-1)*rows;
        int pageSize=rows;
        return departmentDao.selectDepartmentByPage(start, pageSize, name);
    }
}
